import { ILoginModel } from '@/models/login'
import { http } from '@/utils/http'

/** 企业微信登录 */
export const login = (params: { app_id: string; code: string }) => {
  return http.post<{ token: string }>('/library-client/api/wxwork/common/login', params)
}

/** 获取 iPad 登录的二维码 */
export const getIpadLoginQrCode = () => {
  return http.get<{ qrcode: string }>('/library-client/api/wxwork/common/get-qr-code')
}

/** 检查登录结果 */
export const checkLoginResult = (params = {}) => {
  return http.get<ILoginModel>('/library-client/api/wxwork/common/check-login-result', params)
}

/** 提交验证码 */
export const verifyCode = (params: { code: string }) => {
  return http.post('/library-client/api/wxwork/common/check-code', params)
}

/** 获取二次验证的二维码 */
export const getSecondQrCode = () => {
  return http.get<{ qrcode: string }>('/library-client/api/wxwork/common/get-secondary-qr-code')
}

/** 退出登录 */
export const logout = () => {
  return http.get('/library-client/api/wxwork/common/login-out')
}
